#include <stdio.h>
int main()
{
    char n[100];
    int zhuanhuan(int a,int b,char *n);
    int a;
    int b;
    int i;
scanf("%d,%d",&a,&b);
zhuanhuan(a,b,n);
for(i=zhuanhuan(a,b,n)-1;i>=0;i--)
        {

          printf("%c",n[i]);


        }
return 0;
}

int zhuanhuan(int a,int b,char *n)
{
    int c=0;
    char k[16]={0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F',};
      do{
           n[c++]=k[a%b];
           a=a/b;
        }while(a!=0);